<?php 
include 'function.php';
$db=(include 'db.php');
include 'message.php';
if(IS_POST){	
	if(is_array($db)){
		if(!empty($_POST['text'])&&!empty($_POST['name'])){
			$_POST['name']=adds_html($_POST['name']);
			$_POST['text']=adds_html($_POST['text']);
		$arr=$_POST;
		$arr['time']=date('Y-m-d H:i:s');
		$db[]= $arr;
		
		}else{
			echo "<script>alert('请认真填写要给我说的话哦O(∩_∩)O~');</script>";
		}
		
	
}else{
	$db=array();
	if(!empty($_POST['text'])&&!empty($_POST['name'])){
			$_POST['name']=adds_html($_POST['name']);
			$_POST['text']=adds_html($_POST['text']);
		$arr=$_POST;
		$arr['time']=date('Y-m-d H:i:s');
		$db[]= $arr;
		
		}else{
			echo "<script>alert('请认真填写要给我说的话哦O(∩_∩)O~');</script>";
		}


}
	$db=array_values($db);
$db=var_export($db,true);

$str=<<<aa
<?php
	return $db;
?>
aa;
	
	file_put_contents('db.php', $str);
	$_POST=null;
echo
	"<script language='JavaScript'>
window.location.href = 'index.php';
</script>";
	
	
}






 ?>